using Geek.Server;
{{~ for use in usingspaces ~}}
using {{use}};
{{~ end ~}}

namespace {{space}}
{
    public class {{name}} : {{super}}
	{
		{{~ for mth in methods ~}}
		
		{{mth.declare}}
		{
			{{~ if mth.discard ~}}{{~#************************************************~}}

			{{~ if mth.threadsafe ~}}
			_ = base.{{mth.name}}{{mth.typeparams}}({{mth.paramstr}});
			{{~ else ~}}
			long callChainId = Geek.Server.Core.Actors.Impl.WorkerActor.NextChainId();
			_ = base.Actor.WorkerActor.Enqueue(()=>{return base.{{mth.name}}{{mth.typeparams}}({{mth.paramstr}});}, callChainId, {{mth.discard}}, {{mth.timeout}});
			{{~ end ~}}
			return {{mth.returntype}}.CompletedTask;

			{{~ else ~}}{{~#************************************************~}}
			(bool needEnqueue, long chainId)= base.Actor.WorkerActor.IsNeedEnqueue();
			if (!needEnqueue)
			{
				return base.{{mth.name}}{{mth.typeparams}}({{mth.paramstr}});
			}
			return base.Actor.WorkerActor.Enqueue(()=>{return base.{{mth.name}}{{mth.typeparams}}({{mth.paramstr}});}, chainId, {{mth.discard}}, {{mth.timeout}});
			{{~ end ~}}{{~#************************************************~}}
		}

		{{~ end ~}}
	}
}